package br.com.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class PropertiesLoader {
	
	public static final String LOCATION_REMOTE_OBJECT = "LocationRemoteObject";
	public static final String PORT_LOCATION_REMOTE_OBJECT = "port.location.remote.object";
	
	public static final String LOCATION_NAMED_SERVICE= "LocationNamedService";
	public static final String PORT_LOCATION_NAMED_SERVICE = "PortLocationNamedService";
	public static final String FIELD_SEPARATOR = "FieldSeparator";
	public static final String END_FIELD_SEPARATOR = "EndFieldSeparator";
	
	//
	public static final String MESSAGE_CHECKER_PERIOD = "MessageCheckerPeriod";
	
	private static final String PROPERTIES_FILE = "middleware.properties";
	public static final String PUBLISH_LOCATION = "publish.location";
	public static final String MAX_TRY_SENDS = "max.try.sends";
	public static final String TIME_OUT_MESSAGE_INFO = "timeout.message.info";
	public static final String TIME_OUT_SUPPLY_LISTENER = "timeout.supply.listener";
	public static final String PORT_FACTORY_RECEIVER = "port.factory.receiver";
	public static final String PORT_MANAGER_RECEIVER = "port.manager.receiver";
	public static final String PORT_SUPPLY_RECEIVER = "port.supply.receiver";
	public static final String CONSUMER_DATABASE = "consumer.database";
	public static final String ENCRIPTION = "encryption";
	
	private static PropertiesLoader instance;
	private Properties props;

	private PropertiesLoader() {
		props = new Properties();

		try {
			props.load(new FileInputStream(PROPERTIES_FILE));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static PropertiesLoader getInstance(){
		if(instance == null){
			instance = new PropertiesLoader();
		}
		return instance;
	}

	public String getPropertie(String property) {
		return props.getProperty(property);
	}

}
